Gef.jbs.ExtEditor = Gef.extend(Gef.jbs.JBSEditor, {
			constructor : function() {
				this.modelFactory = new Gef.jbs.JBSModelFactory();
				this.editPartFactory = new Gef.jbs.JBSEditPartFactory();
				this.editDomain = this.createEditDomain();
				this.graphicalViewer = this.createGraphicalViewer();
			},
			addSelectionListener : function(selectionListener) {
				this.getGraphicalViewer().getBrowserListener().selectionListenerTracker.addSelectionListener(selectionListener);
			},
			addWidth : function($) {
				if (Gef.isVml)
					;
				else {
					var _ = document.getElementById("_Gef_0"), A = parseInt(_.getAttribute("width"), 10);
					_.setAttribute("width", A + $)
				}
			},
			addHeight : function($) {
				if (Gef.isVml)
					;
				else {
					var A = document.getElementById("_Gef_0"), _ = parseInt(A.getAttribute("height"), 10);
					A.setAttribute("height", _ + $)
				}
			},
			createGraphicalViewer : function() {
				return new Gef.jbs.ExtGraphicalViewer(this);
			},
			clear : function() {
				var D = this.getGraphicalViewer(), A = D.getContents(), C = D.getBrowserListener(), _ = D.getEditDomain().getCommandStack(), $ = C.getSelectionManager();
				$.selectAll();
				var B = A.getRemoveNodesCommand({
							role : {
								nodes : $.getSelectedNodes()
							}
						});
				_.execute(B);
				$.clearAll();
				this.editDomain.editPartRegistry = []
			},
			createEditDomain : function() {
				var $ = new Gef.gef.EditDomain();
				$.setEditor(this);
				return $
			},
			getPaletteHelper : function() {
				if (!this.paletteHelper) {
					this.paletteHelper = new Gef.jbs.ExtPaletteHelper(this);
				}
				return this.paletteHelper;
			},
			getGraphicalViewer : function() {
				return this.graphicalViewer
			},
			getEditDomain : function() {
				return this.editDomain
			},
			getModelFactory : function() {
				return this.modelFactory
			},
			getEditPartFactory : function() {
				return this.editPartFactory
			},
			disable : function() {
				this.getGraphicalViewer().getBrowserListener().disable();
			},
			enable : function() {
				this.getGraphicalViewer().getBrowserListener().enable();
			},
			init : function($) {
				var _ = $.getObject();
				this.getGraphicalViewer().setContents(_);
				this.editDomain = new Gef.gef.EditDomain();
				this.editDomain.setEditor(this);
				this.updateModelFactory()
			},
			reset : function() {
				this.clear();
				var A = this.getGraphicalViewer(), $ = A.getEditDomain().getCommandStack();
				$.flush();
				this.getModelFactory().reset();
				var _ = A.getContents();
				_.text = "untitled";
				_.key = null;
				_.description = null
			},
			resetAndOpen : function($) {
				this.reset();
				var A = new Gef.jbs.xml.JBSDeserializer($), _ = A.decode();
				this.getGraphicalViewer().setContents(_);
				this.updateModelFactory();
				this.getGraphicalViewer().getContents().refresh()
			},
			render : function() {
				this.getGraphicalViewer().render()
			},
			serial : function() {
				var $ = this.getGraphicalViewer().getContents().getModel(), _ = new Gef.jbs.xml.JBSSerializer($), A = _.serialize();
				return A
			},
			setWorkbenchPage : function($) {
				this.workbenchPage = $
			},
			setGraphicalViewer : function($) {
				this.graphicalViewer = $
			},
			setEditDomain : function($) {
				this.editDomain = $
			},
			setModelFactory : function($) {
				this.modelFactory = $
			},
			setEditPartFactory : function($) {
				this.editPartFactory = $
			},
			updateModelFactory : function() {
				var A = this.getGraphicalViewer().getContents().getModel(), _ = this.getModelFactory(), $ = {};
				Gef.each(A.getChildren(), function(E) {
							var H = E.getType(), C = E.text;
							if (!C)
								return true;
							var A = _.getTypeName(H), D = A + " ";
							if (C.indexOf(D) != 0)
								return true;
							var G = C.substring(D.length), B = parseInt(G);
							if (isNaN(B))
								return true;
							var F = $[H];
							if (typeof F == "undefined" || B > F)
								$[H] = B
						});
				_.map = $
			}
			
		});
		
Gef.jbs.JBSModelFactory = Gef.extend(Gef.gef.ModelFactory, {
			createModel : function(type) {
				var id = this.getId(type);
				return Gef.jbs.JBSModelFactory._modelLib[type] ? eval("new " + Gef.jbs.JBSModelFactory._modelLib[type] + "({id:id,text:id})") : null
			},
			getId : function($) {
				if (this.map == null)
					this.map = {};
				if (this.map[$] == null)
					this.map[$] = 1;
				else
					this.map[$]++;
				return $ + " " + this.map[$]
			},
			getTypeName : function($) {
				return $
			},
			reset : function() {
				delete this.map;
				this.map = {}
			}
		});
Gef.jbs.JBSEditPartFactory = Gef.extend(Gef.gef.EditPartFactory, {
			createEditPart : function(type) {
				return Gef.jbs.JBSEditPartFactory._editPartLib[type] ? eval("new " + Gef.jbs.JBSEditPartFactory._editPartLib[type] + "(type)") : null
			}
		});
Gef.gef.EditDomain = Gef.extend(Object, {
			constructor : function() {
				this.commandStack = new Gef.commands.CommandStack();
				this.editPartRegistry = {};
				this.model2EditPart = {};
				this.figure2EditPart = {}
			},
			getCommandStack : function() {
				return this.commandStack
			},
			setEditor : function($) {
				this.editor = $
			},
			createEditPart : function(_) {
				var $ = _.getId(), A = _.getType(), B = this.editor.getEditPartFactory().createEditPart(A);
				this.editPartRegistry[$] = B;
				B.setModel(_);
				this.registerModel(B);
				return B
			},
			findOrCreateEditPart : function(_) {
				var $ = _.getId(), A = _.getType(), B = this.editPartRegistry[$];
				if (!B)
					B = this.createEditPart(_);
				return B
			},
			registerModel : function(A) {
				var _ = A.getModel(), $ = _.getId();
				if (this.model2EditPart[$] != null)
					this.model2EditPart[$] = A
			},
			findModelByEditPart : function(_) {
				var $ = _.getId();
				return this.model2EditPart[$]
			},
			removeModelByEditPart : function(A) {
				var _ = A.getModel(), $ = _.getId();
				if (this.model2EditPart[$] != null) {
					this.model2EditPart[$] = null;
					delete this.model2EditPart[$]
				}
			},
			registerFigure : function(_) {
				var $ = _.getFigure(), A = $.getId();
				if (this.figure2EditPart[A] != null)
					this.figure2EditPart[A] = _
			},
			findFigureByEditPart : function($) {
				var _ = $.getId();
				return this.figure2EditPart[_]
			},
			removeFigureByEditPart : function(_) {
				var $ = _.getFigure(), A = $.getId();
				if (this.figure2EditPart[A] != null) {
					this.figure2EditPart[A] = null;
					delete this.figure2EditPart[A]
				}
			}
		});

Gef.jbs.ExtGraphicalViewer = Gef.extend(Gef.gef.support.DefaultGraphicalViewer, {
			constructor : function($) {
				this.editor = $;
				this.rootEditPart = this.createRootEditPart();
				Gef.gef.support.DefaultGraphicalViewer.superclass.constructor.call(this);
				this.browserListener = new Gef.gef.tracker.BrowserListener(this)
			},
			createRootEditPart : function() {
				return new Gef.gef.support.DefaultRootEditPart(this)
			},
			getActivePalette : function() {
				return this.editor.getPaletteHelper().getActivePalette()
			},

			getPaletteLocation : function() {
				if (!this.paletteLocation) {
					var paletteBox = Ext.get('__gef_jbs_palette__').getBox();
					this.paletteLocation = {
						x : paletteBox.x,
						y : paletteBox.y,
						w : paletteBox.width,
						h : paletteBox.height
					};
				}
				return this.paletteLocation;
			},

			getCanvasLocation : function() {
				var box = Ext.get('__gef_jbs_center__').getBox();
				var scroll = Ext.get('__gef_jbs_center__').getScroll();
				this.canvasLocation = {
					x : box.x,
					y : box.y,
					w : box.width,
					h : box.height
				};
				return this.canvasLocation;
			},
			getEditDomain : function() {
				return this.editor.getEditDomain()
			},
			getEditPartFactory : function() {
				return this.editor.editPartFactory
			},
			getLayer : function($) {
				return this.rootEditPart.getFigure().getLayer($)
			},
			getPaletteConfig : function(_, $) {
				return this.editor.getPaletteHelper().getPaletteConfig(_, $)
			},
			getEditor : function() {
				return this.editor
			},
			getBrowserListener : function() {
				return this.browserListener
			},
			render : function() {
				this.canvasEl = Ext.getDom('__gef_jbs_center__');
				this.rootEditPart.render();
				this.rendered = true;
			},
			setContents : function(_) {
				var $ = null, D = null;
				if (typeof _ == "string") {
					D = _;
					var C = this.editor.getModelFactory();
					$ = C.createModel(_)
				} else {
					$ = _;
					D = $.getType()
				}
				var B = this.editor.getEditPartFactory(), A = B.createEditPart(D);
				A.setModel($);
				this.rootEditPart.setContents(A)
			}
		});